import {
  ShapeCustomizationManagementModel,
  ShapeStyleValue
} from "@/modules/model/modals/shapeCustomization/ShapeCustomizationManagementModel";
import { markRaw } from "vue";
import FontFamilyComps from "@/modules/model/modals/shapeCustomization/comps/valueComps/FontFamilyComps.vue";
import FontSizeComps from "@/modules/model/modals/shapeCustomization/comps/valueComps/FontSizeComps.vue";
import ColorFillComps from "@/modules/model/modals/shapeCustomization/comps/valueComps/ColorFillComps.vue";
import FontStyleComps from "@/modules/model/modals/shapeCustomization/comps/valueComps/FontPatternComps.vue";

export const valueCompsMap = {
  fontFamily: markRaw(FontFamilyComps),
  fontSize: markRaw(FontSizeComps),
  color: markRaw(ColorFillComps),
  fontStyle: markRaw(FontStyleComps)
};

export const shapeStyleInfo: ShapeStyleValue[] = [
  {
    enName: "Font family",
    enTips: "",
    key: "fontFamily",
    name: "字体",
    value: ""
  },
  {
    enName: "Font size",
    enTips: "",
    key: "fontSize",
    name: "字号",
    value: undefined
  },
  {
    enName: "Font color",
    enTips: "",
    key: "color",
    name: "颜色",
    value: ""
  },
  {
    enName: "Font Style",
    enTips: "",
    key: "fontStyle",
    name: "字形",
    value: ""
  }
];

export class ShapeNameStyleConfigModel {
  shapeStyleInfo = shapeStyleInfo;
  shapeStyleMap = new Map<string, ShapeStyleValue>();
  constructor(public shapeCustomizationManagementModel: ShapeCustomizationManagementModel) {
    shapeStyleInfo.forEach(v => {
      this.shapeStyleMap.set(v.key, v);
    });
  }

  initNameStyleConfig(row) {
    for (const key in row) {
      if (this.shapeStyleMap.get(key)) {
        this.shapeStyleMap.get(key)!.value = row[key];
      }
    }
  }
}
